package com.five.monkey.feign.provider.convert;

import com.five.monkey.feign.provider.dao.model.GraphModel;
import com.five.monkey.util.TimeUtils;
import com.five.monkey.vo.GraphVo;
import java.util.Objects;

/**
 * @author 狻猊
 * @date 2021/8/10 下午2:42
 */
public class GraphConvert {

    private GraphConvert() {}

    /**
     * do -> vo
     * @param graphModel
     * @return
     */
    public static GraphVo model2vo(GraphModel graphModel) {
        if (Objects.isNull(graphModel)) {
            return null;
        }
        GraphVo vo = new GraphVo();
        vo.setId(graphModel.getId()).setTitle(graphModel.getTitle()).setUserId(graphModel.getUserId())
                .setStatus(graphModel.getStatus()).setCreateTime(TimeUtils.parseDate(graphModel.getCrateTime()))
                .setUpdateTime(TimeUtils.parseDate(graphModel.getUpdateTime()));
        return vo;
    }

    public static GraphModel vo2model(GraphVo graphVo) {
        if (Objects.isNull(graphVo)) {
            return null;
        }
        GraphModel model = new GraphModel();
        model.setId(graphVo.getId()).setTitle(graphVo.getTitle()).setStatus(graphVo.getStatus())
                .setUserId(graphVo.getUserId()).setCrateTime(TimeUtils.ofDate(graphVo.getCreateTime()))
                .setUpdateTime(TimeUtils.ofDate(graphVo.getUpdateTime()));
        return model;
    }
}
